Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4415

SqlStdOperatorTable.NOT_LIKE has a wrong implementor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.27.0
    • None

    Description

      SqlStdOperatorTable.NOT_LIKE's implementor defined in RexImpTable is currently the same as LIKE (i.e. NOT_LIKE performs the same operation as LIKE):

      ...
      final MethodImplementor likeImplementor =
              new MethodImplementor(BuiltInMethod.LIKE.method, NullPolicy.STRICT, false);
      map.put(LIKE, likeImplementor);
      map.put(NOT_LIKE, likeImplementor);
      

      It should be:

      ...
      map.put(LIKE, likeImplementor);
      map.put(NOT_LIKE, NotImplementor.of(likeImplementor));
      

      Luckily, SQL queries seem to not suffer the consequences because StandardConvertletTable expands x NOT LIKE y into NOT (x LIKE y), so the issue is avoided:

      // Expand "x NOT LIKE y" into "NOT (x LIKE y)"
      registerOp(SqlStdOperatorTable.NOT_LIKE,
          (cx, call) -> cx.convertExpression(
              SqlStdOperatorTable.NOT.createCall(SqlParserPos.ZERO,
                  SqlStdOperatorTable.LIKE.createCall(SqlParserPos.ZERO,
                      call.getOperandList()))));
      

      However, creating a plan via RelBuilder using SqlStdOperatorTable.NOT_LIKE will lead to incorrect results.

      Attachments

        Activity

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 10m
                1h 10m